package edu.sctu.xialei.May.day20150517three;


/**
 * Created by Administrator on 2015/5/17 0017.
 */
public class TextMore {

    public int[] sortNumber(TeaCher[] teaChers){

        int a[] = new int[teaChers.length];

        for (int i = 0; i < teaChers.length; i++) {
            a[i] = teaChers[i].number;

        }

        int temp=0;
            for(int i = a.length-1;i>0;--i)
            {
                for(int j = 0;j < i;++j)
                {
                    if(a[j+1] < a[j])
                    {
                        temp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = temp;
                    }
                }
            }
        return a;
    }


        public Student[] sortStudent(Student[] all_Students){

//        Student[] Students = new Student[all_Students.length];

        Student temp = new Student();
        for(int i = all_Students.length-1;i>0;--i)
        {
            for(int j = 0;j < i;++j)
            {
                if(all_Students[j+1].grade < all_Students[j].grade)
                {
                    temp = all_Students[j];
                    all_Students[j] = all_Students[j+1];
                    all_Students[j+1] = temp;
                }
            }
        }

        return all_Students;
    }


    public TeaCher[] printCoded(TeaCher[] teaChers){

        TeaCher[] teaChers_re = new  TeaCher[teaChers.length];

        TeaCher[] teaChers_return = new  TeaCher[teaChers.length];

        int counter = 0;
        for (int i = 0; i < teaChers.length; i++) {
            if( (teaChers[i].title).equals("教授") ){
                teaChers_re[counter] = teaChers[i];
                counter++;
            }
        }

        for (int i = 0; i < counter; i++) {

            teaChers_return[i] = teaChers_re[i];
        }

        return teaChers_return;
    }
}
